package com.tvshows.front.view.favorite;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;

import com.tvshows.front.listener.command.interfaces.FavoriteCommandListener;
import com.tvshows.front.ui.favorite.UpsideCompositeFavoriteUI;
import com.tvshows.front.view.labels.FrontButton;

/**
 * @author tMidy
 * <p>
 * This class constitutes the upside panel of the favoriteFrame (right side)
 * </p>
 */
public class UpsideCompositeFavoriteView
    extends Composite
    implements UpsideCompositeFavoriteUI
{

    /**
     * The buttons
     */
    private FrontButton addFavorite, deleteFavorite, modifyFavorite;

    /**
     * Constructor of the class
     * 
     * @param parent superParent
     * @param style superStyle
     */
    public UpsideCompositeFavoriteView( Composite parent, int style )
    {
        super( parent, style );
        this.setLayout( new RowLayout() );
        initButtons();
    }

    /**
     * This method initializes the buttons of the panel
     */
    public void initButtons()
    {
        /*
         * The listener
         */
        FavoriteCommandListener favoriteCommandListener = new FavoriteCommandListener( this );

        addFavorite = new FrontButton( this, SWT.NONE );
        addFavorite.setText( "Ajouter un nouveau favori..." );
        addFavorite.addListener( SWT.Selection, favoriteCommandListener );

        modifyFavorite = new FrontButton( this, SWT.NONE );
        modifyFavorite.setText( "Modifier le favori sélectionné..." );
        modifyFavorite.setEnabled( false );
        modifyFavorite.addListener( SWT.Selection, favoriteCommandListener );

        deleteFavorite = new FrontButton( this, SWT.NONE );
        deleteFavorite.setText( "Supprimer le(s) favoris sélectionnés" );
        deleteFavorite.setEnabled( false );
        deleteFavorite.addListener( SWT.Selection, favoriteCommandListener );
    }

    /**
     * @return the addFavorite
     */
    @Override
    public Button getAddFavorite()
    {
        return addFavorite;
    }

    /**
     * @return the deleteFavorite
     */
    @Override
    public Button getDeleteFavorite()
    {
        return deleteFavorite;
    }

    /**
     * @return the modifyFavorite
     */
    @Override
    public Button getModifyFavorite()
    {
        return modifyFavorite;
    }

    /**
     * @see com.tvshows.front.ui.favorite.UpsideCompositeFavoriteUI#enableDelete(boolean)
     */
    @Override
    public void enableDelete( boolean delete )
    {
        this.deleteFavorite.setEnabled( delete );
        this.modifyFavorite.setEnabled( delete );
    }

    @Override
    public void initFormData()
    {

    }

    @Override
    public void initComposites()
    {

    }

}
